home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / STARS3D.ZIP / MCGA.PAS < prev    next >
Pascal/Delphi Source File  |  1995-12-22  |  2KB  |  94 lines

  1. Unit MCGA;
  2.  
  3. Interface
  4. Uses Crt;
  5.  
  6. Procedure Gmode;
  7. Procedure Tmode;
  8. Procedure Flip;
  9. Procedure PutPixel(X,Y : Word; Col : byte; Where : Word);
  10. Procedure SetPal(Col,R,G,B : Byte);
  11. Procedure Clscr(Col : Word);
  12.  
  13. Const VGA = $A000;
  14.  
  15. Type
  16.     VScr = ^VirtScreen;
  17.     VirtScreen = Array[1..64000] Of Byte;
  18.  
  19. Var
  20.     VirScr : VScr;
  21.     VirAddr : Word;
  22.  
  23.  
  24. Implementation
  25.  
  26.  
  27. Procedure Gmode;
  28. Begin
  29. asm
  30.    mov ax,13h
  31.    int 10h
  32. end;
  33.     GetMem(VirScr,64000);
  34.     VirAddr := Seg(VirScr^);
  35.     Fillchar(VirScr^,64000,0);
  36. end;
  37.  
  38.  
  39. Procedure Clscr(Col : Word);
  40. Begin
  41.      Fillchar(VirScr^,64000,Col);
  42. end;
  43.  
  44.  
  45. Procedure Tmode;
  46. Begin
  47. asm
  48.    mov ax,3h
  49.    int 10h
  50.  
  51. end;
  52.     Freemem(VirScr,64000);
  53. end;
  54.  
  55.  
  56. Procedure Flip;assembler; {to make virtual Flip(Source,Dest : Word}
  57. asm
  58.    push ds        {STORE DS REGISTER}
  59.    mov ax,$0a000  {ADDRESS VIDEO MEMORY}
  60.    mov es,ax      {MOV IT TO EXTRA SEG dont know why yet}
  61.    xor di,di      {CLEAR DI/SI = 0 = MOV DI,0}
  62.    xor si,si
  63.    mov ds,Viraddr {ADDRESS THE VIRTUAL SCREEN swap ax and ds to reverse screens}
  64.    mov cx,64000   {SET A LOOP OF 64k SCREEN}
  65.    rep movsw      {REPEAT IT MOV WORD dont know what it does}
  66.    pop ds
  67.    {Move(VirScr^,Mem[VGA:0],64000); }
  68. end;
  69.  
  70.  
  71. Procedure SetPal(Col,R,G,B : Byte); assembler;
  72. asm
  73.    mov dx,$3c8        {Port[$3c8] := Col}
  74.    mov al,[Col]
  75.    out dx,al          {Dx Data Reg / I/O}
  76.    mov dx,$3c9        {Inc Dx May Be Faster}
  77.    mov al,R           {Port[$3c9] := R}
  78.    out dx,al
  79.    mov al,G           {Port[$3c9] := G}
  80.    out dx,al
  81.    mov al,B           {Port[$3c9] := B}
  82.    out dx,al
  83. end;
  84.  
  85.  
  86.  
  87. Procedure PutPixel(X,Y : Word; Col : Byte; Where : Word);
  88. Begin
  89.      {Asm Way Is Much Longer And Pointless To Me At The Moment}
  90.      Mem[Where:Y*320+X] := Col
  91. end;
  92.  
  93. end.
  94.